package cn.zmwh.portal.modules.index.controller;


import cn.zmwh.common.core.api.Result;
import cn.zmwh.common.core.constants.Constants;
import cn.zmwh.portal.modules.index.mapper.TlTopicMapper;
import cn.zmwh.portal.modules.index.pojo.entity.TlTopic;
import cn.zmwh.portal.modules.index.pojo.vo.TlTopicVo;
import cn.zmwh.portal.modules.index.service.TlTopicService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author dmzmwh
 * @since 2024-08-26
 */
@Api(tags = "来源隔离-租户")
@RestController
@RequestMapping(value = {"/index/topic", "/tl/api/topic"})
public class TlTopicController {


    @Autowired
    TlTopicMapper tlTopicMapper;
    @Autowired
    TlTopicService tlTopicService;

    @GetMapping
    @ApiOperation(value = "话题")
    public Result topic() {
        List<TlTopic> tlTopics = tlTopicMapper.selectList(Wrappers.<TlTopic>lambdaQuery()
                .eq(TlTopic::getOrigin, 1)
                .eq(TlTopic::getShow, 1)
                .orderByDesc(TlTopic::getSort));

        return Result.ok(tlTopics);
    }

    @GetMapping("/circle")
    @ApiOperation(value = "话题+圈子")
    public Result<List<TlTopicVo>> topicCircle(@ApiIgnore @RequestHeader(value = Constants.UID, required = false) Long tlId) {
        return tlTopicService.topicCircle(tlId);
    }

}

